from PyQt5.QtCore import QObject, pyqtSignal
import time

from base_api.MessageClass import Message


class HelloWorldTask(QObject):
    signal = pyqtSignal(object)

    def __init__(self):
        super().__init__()
        self.name = ''

    def execute(self):
        # 单纯的信号机制并不能解决休眠导致的未响应问题
        # time.sleep(5)
        self.signal.emit(Message(1, 'Hello world, %s' % self.name))
        self.signal.emit(Message(1, '123'))
        # 线程执行完毕
        self.signal.emit(Message(-1, ''))

